<?php
//网站APP命名空间: IKPHP\Apps\Space\Models => apps/AppName/models/
foreach ($modules as $key=>$name){
	$appmodules['IKPHP\\Apps\\'.ucfirst($key)] = $config->application->appsDir.$key.'/';
	$appmodules['IKPHP\\Apps\\'.ucfirst($key).'\\Models'] = $config->application->appsDir.$key.'/models/';
	//控制器
	$appmodules['IKPHP\\Apps\\'.ucfirst($key).'\\Controllers'] = $config->application->appsDir.$key.'/controllers/';
}
//网站公共组件命名空间
$spaces = array(
	'IKPHP\Apps'      => $config->application->appsDir,
	'IKPHP\Common'    => $config->application->commmonDir,
	'IKPHP\Vendor'    => $config->application->vendorDir,
	'IKPHP\Org'       => $config->application->orgDir,
	'IKPHP\Api'       => $config->application->apiDir,
	'IKPHP\Plugins'   => $config->application->pluginsDir,
);

$loader = new \Phalcon\Loader();
//注册公用组件目录
$loader->registerNamespaces(array_merge($spaces, $appmodules));

$eventsManager = new \Phalcon\Events\Manager();
//接听装置了哪些目录
$eventsManager->attach('loader', function($event, $loader) use ($di){
    if ($event->getType() == 'beforeCheckPath') {
        $di->get('logger')->log('加载文件：'.$loader->getCheckedPath());
    }
});
$loader->setEventsManager($eventsManager);

$loader->register();
